package com.semac.server.database.fetchers;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.semac.server.database.classesbase.AbstractDataFetcher;
import com.semac.shared.model.SemanaAcademica;

public class SemanaAcademicaDataFetcher extends AbstractDataFetcher<SemanaAcademica> {

	public SemanaAcademicaDataFetcher(String whereString) {
		super(whereString);
	}

	@Override
	protected String getColumnsToBeSelected() {
		return "*";
	}

	@Override
	protected String getTableToBeSelected() {		
		return "\"semana_academica\"";
	}

	@Override
	public void fetchDataFromResultSet(ResultSet resultSet) throws SQLException {
		while (resultSet.next()){
			SemanaAcademica semanac = new SemanaAcademica();
			semanac.setCodSemana(resultSet.getInt("codSemana"));
			semanac.setAtiva(resultSet.getBoolean("ativa"));
			semanac.setDataIni(resultSet.getTimestamp("dataIni"));
			semanac.setDataFim(resultSet.getTimestamp("dataFim"));
			semanac.setInicioInscricao(resultSet.getTimestamp("dataIniInscricoes"));
			semanac.setFimInscricao(resultSet.getTimestamp("dataFimInscricoes"));
			semanac.setDescricao(resultSet.getString("descricao"));
			
			this.results.add(semanac);
		}
	}

}
